﻿<%@ Page Language="C#" MasterPageFile="~/Member.Master" AutoEventWireup="true" CodeBehind="Register.aspx.cs"
    Inherits="Continental.UI.Member.Register" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link media="screen" href="/JavaScript/ColorBox/colorbox.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script src="/JavaScript/ColorBox/jquery.colorbox.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        var isEmail = true;
        var isPassword = true;
        var message = "";
		$(document).ready(function(){
			$("#dieukhoan").colorbox({width:"50%", inline:true, href:"#dieukhoan_conten"});
			$("#<%=btnRegister.ClientID%>").attr("disabled", "disabled");

            $("#ckOK").click(function() {
                var checked_status = this.checked;
                if (checked_status == true) {
                     $("#<%=btnRegister.ClientID%>").removeAttr("disabled");
                }
                else {
                    $("#<%=btnRegister.ClientID%>").attr("disabled", "disabled");
                }
            });
            
            $("#<%=txtEmail.ClientID%>").blur(function() {
                var email = $("#<%=txtEmail.ClientID%>").val().trim();
                if (email == "")
                {   
                    $("#sEmail").hide();
                    isEmail = false;
                    return;
                }
                else
                {
                    $.ajax({
                        type: "POST",
                        url: "/WS.asmx/EmailExits",
                        data: "{email:'" + email +"'}", 
                        contentType: "application/json; charset=utf-8", 
                        dataType: "json",
                        success: function(result) {
                            if(result.d)
                            {
                                $("#sEmail").text("Email đã tồn tại");
                                $("#sEmail").show();
                                isEmail = false;
                            }
                            else
                            {
                                $("#sEmail").html(""); 
                                $("#sEmail").hide();
                                isEmail = true;
                            }
                        }
                    });
                }
            });
            
            $("#<%=txtPassword.ClientID%>").blur(function() {
                var password = $("#<%=txtPassword.ClientID%>").val().trim();
                if (password == "")
                {
                    $("#sPassword").hide();
                    isPassword = false;
                    return;
                }
                if (password.length > 15 || password.length < 6)
                {
                    $("#sPassword").text("Mật khẩu phải có 6->15 kí tự");
                    $("#sPassword").show();
                    isPassword = false; 
                }
                else
                {
                    $("#sPassword").text("");
                    $("#sPassword").hide();
                    isPassword = true;
                }
            });
		});
    </script>

    <div class="box_container" style="width: 650px; margin-top: 10px;">
        <div class="title_bar">
            <div>
                Đăng kí</div>
        </div>
        <div style="padding-left: 10px; padding-right: 10px; color: #7A2C01" class="popup_Body">
            <table class="list" cellpadding="0" cellspacing="0">
                <tbody>
                    <td colspan="2">
                        <span style="color: Red;" id="message">
                            <%= message%>
                        </span>
                    </td>
                    <tr>
                        <td>
                            <span>Địa chỉ Email : </span>
                        </td>
                        <td>
                            <asp:TextBox ID="txtEmail" CssClass="txt_s" runat="server" MaxLength="100"></asp:TextBox>
                            <span id="sEmail" visible="false" class="error"></span>
                            <asp:RequiredFieldValidator ID="rfvEmail" ControlToValidate="txtEmail" runat="server"
                                ErrorMessage="*"></asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="revEmail" ControlToValidate="txtEmail" runat="server"
                                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ErrorMessage="Email không hợp lệ"></asp:RegularExpressionValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span>Tên đầy đủ : </span>
                        </td>
                        <td>
                            <asp:TextBox ID="txtFullname" CssClass="txt_s" runat="server" MaxLength="100"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvFullname" ControlToValidate="txtFullname" runat="server"
                                ErrorMessage="*"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span>Mật khẩu : </span>
                        </td>
                        <td>
                            <asp:TextBox ID="txtPassword" CssClass="txt_s" runat="server" TextMode="Password" MaxLength="15"></asp:TextBox>
                            <span id="sPassword" visible="false" class="error"></span>
                            <asp:RequiredFieldValidator ID="rfvPassword" ControlToValidate="txtPassword" runat="server"
                                ErrorMessage="*"></asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="revPassword" ControlToValidate="txtPassword"
                                ValidationExpression="[a-zA-Z0-9@#$]+" runat="server" ErrorMessage="Mật khẩu chỉ gồm kí tự : a->z A->Z 1->9 @ # $"></asp:RegularExpressionValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span>Gõ lại mật khẩu : </span>
                        </td>
                        <td>
                            <asp:TextBox ID="txtPassword2" CssClass="txt_s" runat="server" TextMode="Password" MaxLength="15"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvPassword2" ControlToValidate="txtPassword2" runat="server"
                                ErrorMessage="*"></asp:RequiredFieldValidator>
                            <asp:CompareValidator ID="cvPassword" runat="server" ControlToValidate="txtPassword2"
                                ControlToCompare="txtPassword" ErrorMessage="2 mật khẩu không khớp"></asp:CompareValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span>Số điện thoại di động : </span>
                        </td>
                        <td>
                            <asp:TextBox ID="txtPhoneNumber" CssClass="txt_s" runat="server" MaxLength="12"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <input id="ckOK" type="checkbox" /><a id="dieukhoan" href="#">Tôi chấp nhân những điều
                                khoản của HaiPhongClick</a>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <asp:Button ID="btnRegister" runat="server" Width="70px" Text="Đăng kí" OnClick="btnRegister_Click" />
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div style='display: none'>
        <div id='dieukhoan_conten' style='padding: 10px; background: #fff;'>
            <p>
                <strong>Điều lệ khi bạn tham gia là thành viên HaiPhongClick</strong></p>
            <p>
                Bạn có thể làm
            </p>
            <p>
                <strong>If you try to open a new ColorBox while it is already open, it will update itself
                    with the new content.</strong>
            </p>
        </div>
    </div>
</asp:Content>
